﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yottamud_Project_V3;
using Yottamud_2013_v3_Main.Game_Files;

namespace Yottamud_2013_v3_Main
{
    class CombatManager
    {
        public delegate void CombatHandler(ResourceTypes.NpcType iMonster);
        private List<ResourceTypes.AlignmentType> AutoAlignmentList = new List<ResourceTypes.AlignmentType>();


        public CombatManager()
        {
            LoadAlignmentList();
        }

        public void AddToAlignmentList(ResourceTypes.AlignmentType iAlign)
        {
            if (!AutoAlignmentList.Contains(iAlign))
            {
                AutoAlignmentList.Add(iAlign);
            }
        }

        public void RemoveFromAlignmentList(ResourceTypes.AlignmentType iAlign)
        {
            if (AutoAlignmentList.Contains(iAlign))
            {
                AutoAlignmentList.Remove(iAlign);
            }
        }

        private void LoadAlignmentList()
        {

            AutoAlignmentList.Add(ResourceTypes.AlignmentType.CHAOTIC_EVIL);
            AutoAlignmentList.Add(ResourceTypes.AlignmentType.EVIL);
            AutoAlignmentList.Add(ResourceTypes.AlignmentType.LAWFUL_EVIL);
            AutoAlignmentList.Add(ResourceTypes.AlignmentType.NEUTRAL_EVIL);

        }

        private bool DetermineIfHostile(ResourceTypes.NpcType iMonster)
        {
            ResourceTypes.AlignmentType alignment = (ResourceTypes.AlignmentType)iMonster.Align;

            if (AutoAlignmentList.Contains(alignment))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public void ProcessCombat(ResourceTypes.NpcType iMonster)
        {

            if (!PlayerManager.PlayerStatusSettings.IsInCombat && DetermineIfHostile(iMonster))
            {
                if (!PlayerManager.PlayerAttackStyle.RoomAttackStyle)
                {
                    MainWindow.SelectedDisplay.DispatchMessage(this, PlayerManager.PlayerAttackStyle.AttackStyle + " " + iMonster.Name + "\r\n");
                    PlayerManager.PlayerStatusSettings.IsInCombat = true;
                }
                else
                {
                    MainWindow.SelectedDisplay.DispatchMessage(this, PlayerManager.PlayerAttackStyle.AttackStyle + "\r\n");
                    PlayerManager.PlayerStatusSettings.IsInCombat = true;
                }
            }
           
        }



    }
}
